<?php
namespace app\index\controller;
use think\Controller;
use think\Db;
use think\facade\Request;
class Feature extends Controller
{
    protected $middleware = ['VerifyLogin'];

    public function info()
    {
        $params = Request::param('', '', 'strip_tags,trim');
        $version = str_replace('.','',$params['version']);

        $record = Db::table('quick_package_version_feature')
                ->where('quick_id',request()->quickAppId)
                ->where('channel_id',request()->channelId)
                ->field('version,download_path,force_update,hot_update,brief')
                ->order('update_time DESC')->findOrEmpty();

        $data['is_update']      = 2;
        $data['force_update']   = 2;
        $data['brief']          = '';
        $data['hot_update']     = 2;
        $data['version']        = $params['version'];
        $data['download_path']  = '';

        if($record)
        {
            $version_new = str_replace('.','',$record['version']);
            if($version_new > $version)
            {
                $data['is_update']      = 1;
                $data['force_update']   = $record['force_update'];
                $data['hot_update']     = $record['hot_update'];
                $data['brief']          = $record['brief'];
                $data['version']        = $record['version'];
                $data['download_path']  = config('img_domain').$record['download_path'];
            }
        }

        return json(['code'=>0,'msg'=>'success','data'=>$data]);
    }
}